home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PRUS101.ZIP / FNOBREAK.ASM < prev    next >
Assembly Source File  |  1994-07-29  |  8KB  |  256 lines

  1. ;
  2. ; FNOBREAK.ASM
  3. ; suggested assembler : TASM >= 1.0
  4. ;
  5. ; Assembler module for FNOBREAK.PAS,
  6. ; { FIDO unit to avoid <Pause>, <ctrl-Break> and <ctrl-alt-Del> }
  7. ;
  8. ;****************************************************************************
  9. ;
  10. ;        RELEASE 1.02ß - as first contained in the file PRUS101.LZH
  11. ;                 by Paul Schubert, 2:244/1181.18, GERMANY
  12. ;
  13. ;               --------------------------------------------
  14. ;                organized for Fido's PASCAL related echoes
  15. ;               --------------------------------------------
  16. ;
  17. ;     06/21/1994 to --/--/---- by Paul Schubert, 2:244/1181.18, GERMANY
  18. ;
  19. ;
  20. ;           Those who contributed to the following piece of source,
  21. ;           listed in alphabethical order:
  22. ;        ================================================================
  23. ;           Paul Schubert
  24. ;        ================================================================
  25. ;
  26. ;****************************************************************************
  27. ;
  28. ; This routine will be hooked in keyboard interrupt 9h
  29. ; in order to catch certain keystrokes as PAUSE, CTRLALTDEL,
  30. ; BREAK and PRTSCR.
  31. ;
  32. ; the keystrokes will be reported to the main programme by the
  33. ; following variables:
  34. ;
  35. ; PAUSEK : BOOLEAN; Pause pressed
  36. ; BREAKK : BOOLEAN; ctrl-alt-Del pressed
  37. ; CTRBRK : BOOLEAN; ctrl-Break pressed
  38. ; PRTSCK : BOOLEAN; shift-PrtScr pressed
  39. ;
  40. ;******************************************************
  41.  
  42. DATA    SEGMENT BYTE PUBLIC
  43.  
  44.         EXTRN   PAUSEK : BYTE
  45.         EXTRN   BREAKK : BYTE
  46.         EXTRN   CTRBRK : BYTE
  47.         EXTRN   PRTSCK : BYTE
  48.  
  49. DATA    ENDS
  50.  
  51. ;****************************************************** Code
  52.  
  53. CODE    SEGMENT BYTE PUBLIC
  54.  
  55.         ASSUME  CS:CODE, DS:DATA
  56.  
  57.         PUBLIC  InitKbdVectors, RestoreKbdVectors;
  58.         PUBLIC  NewInt09,NewInt05,PrintScreen
  59.  
  60. ;CS-relative variables, easily accessible to interrupt handlers
  61. PrevInt09       LABEL DWORD
  62. PrevInt09Ofs    DW ?
  63. PrevInt09Seg    DW ?
  64. PrevInt05       LABEL DWORD
  65. PrevInt05Ofs    DW ?
  66. PrevInt05Seg    DW ?
  67.  
  68. ;*********************************************************** NewInt05
  69. ;Handle PRTSCR interrupt
  70.  
  71. NewInt05        PROC FAR
  72.  
  73.         PUSH    AX
  74.         PUSH    DS
  75.         MOV     AX,SEG DATA
  76.         MOV     DS,AX                   ;Point to Turbo data area
  77.         MOV     PRTSCK,0FFH             ; PRINT SCREEN MARKIEREN
  78.         POP     DS
  79.         POP     AX
  80.         IRET                            ;Return to caller
  81.  
  82. NewInt05        ENDP
  83.  
  84. ;*********************************************************** NewInt05
  85. ; CALL old PRINTSCREEN handler
  86.  
  87. PrintScreen     PROC FAR
  88.  
  89.         PUSHF
  90. ;       JMP     PrevInt05               ;Transfer to previous interrupt 05
  91.         CALL    CS:PrevInt05            ;Transfer to previous interrupt 05
  92.         RET
  93.  
  94. PrintScreen     ENDP
  95.  
  96. ;*********************************************************** NewInt09
  97. ;Handle hardware keyboard interrupts
  98.  
  99.         BiosShiftFlags  EQU BYTE PTR 17h  ;Addresses in BIOS data area
  100.         E0FLAG          EQU BYTE PTR 96H
  101.  
  102. NewInt09        PROC FAR
  103.  
  104.         STI                             ;Interrupts on
  105.         PUSH    AX                      ;Save registers we use
  106.         PUSH    BX
  107.         PUSH    CX
  108.         PUSH    DS
  109.  
  110.         MOV     AX,0040h
  111.         MOV     DS,AX                   ;Point to BIOS data area
  112.         IN      AL,60h                  ;Read scan code
  113.  
  114.         CMP     AL,45H                  ; PAUSE ?
  115.         JE      PAUSE                   ; JA - ABFANGEN
  116.  
  117.         TEST    DS:BIOSSHIFTFLAGS,00000100B
  118.         JE      INT09ORIG               ; NUR CTRL TESTEN
  119.  
  120.         CMP     AL,46H                  ; BEI CTRL-BREAK KOMMT MAKECODE E0 46
  121.         JE      CTRLBR
  122.  
  123.         TEST    DS:BIOSSHIFTFLAGS,00001000B
  124.         JNE     CTRLALT                 ; Ctrl-Alt : AUF Del TESTEN
  125.  
  126. Int09Orig:                              ;Let BIOS int 09 handler take care of it
  127.         POP     DS                      ;Restore registers
  128.         POP     CX
  129.         POP     BX
  130.         POP     AX
  131.         JMP     PrevInt09               ;Transfer to previous interrupt 09
  132.  
  133. PAUSE:
  134.         TEST    DS:BIOSSHIFTFLAGS,00000100B
  135.         JNE     _PAUSE                  ; CTRL IST BEI K3P GESETZT
  136.         TEST    DS:E0FLAG,00000001b     ; E1- FLAG GESETZT ? ( FÜR KEYB )
  137.         JE      INT09ORIG
  138. _PAUSE: MOV     AX,SEG DATA
  139.         MOV     DS,AX                   ;Point to Turbo data area
  140.         MOV     PAUSEK,0FFH             ; PAUSE MARKIEREN
  141.         JMP     ZURUECK
  142.  
  143. CTRLBR:
  144. ;       TEST    DS:E0FLAG,00000010b     ; E0- FLAG GESETZT ?
  145. ;       JE      INT09ORIG
  146.  
  147. ;       AND     DS:E0FLAG,11111101B     ; RESET E0- FLAG
  148.         MOV     AX,SEG DATA
  149.         MOV     DS,AX                   ;Point to Turbo data area
  150.         MOV     CTRBRK,0FFH             ; BREAK MARKIEREN
  151.         JMP     ZURUECK
  152.  
  153. CTRLALT:
  154.         IN      AL,60h                  ;Read scan code
  155.         CMP     AL,53H                  ;Is it 53h?
  156.         JNE     Int09Orig               ;If not, pass on to BIOS int 09 handler
  157.  
  158. ISBREAK:
  159.         AND     DS:E0FLAG,11111101B     ; RESET E0- FLAG
  160.         MOV     AX,SEG DATA
  161.         MOV     DS,AX                   ;Point to Turbo data area
  162.         MOV     BREAKK,0FFH             ; CTRL- ALT- DEL MARKIEREN
  163.  
  164. ; TASTATURCODE VERNICHTEN UND ZURÜCK
  165. ZURUECK:
  166.         IN      AL,61h                  ;Read control port value
  167.         MOV     AH,AL                   ;Save in AH
  168.         OR      AL,80h                  ;Set high bit
  169.         OUT     61h,AL                  ;Reset keyboard
  170.         MOV     AL,AH                   ;Retrieve original value
  171.         OUT     61h,AL                  ;Enable keyboard
  172.         CLI                             ;Stop CPU interrupts
  173.         MOV     AL,20h                  ;End of interrupt
  174.         OUT     20h,AL                  ;To the interrupt controller
  175.  
  176.         STI                             ;Interrupts on
  177.         POP     DS                      ;Restore registers
  178.         POP     CX
  179.         POP     BX
  180.         POP     AX
  181.         IRET                            ;Return to caller
  182.  
  183. NewInt09        ENDP
  184.  
  185. ;*********************************************************** InitKbdVectors
  186.  
  187. ;Save and setup interrupt vectors
  188.  
  189. InitKbdVectors  PROC FAR
  190.  
  191.         MOV     AX,3509h                ;Get current int 9
  192.         INT     21h
  193.         MOV     PrevInt09Ofs,BX         ;Save it in CS-relative variables
  194.         MOV     PrevInt09Seg,ES
  195.         PUSH    DS
  196.         PUSH    CS
  197.         POP     DS
  198.         MOV     DX,offset NewInt09
  199.         MOV     AX,2509h                ;Install new int 9
  200.         INT     21h
  201.         POP     DS
  202.  
  203.         MOV     AX,3505h                ;Get current int 5
  204.         INT     21h
  205.         MOV     PrevInt05Ofs,BX         ;Save it in CS-relative variables
  206.         MOV     PrevInt05Seg,ES
  207.         PUSH    DS
  208.         PUSH    CS
  209.         POP     DS
  210.         MOV     DX,offset NewInt05
  211.         MOV     AX,2505h                ;Install new int 5
  212.         INT     21h
  213.         POP     DS
  214.  
  215.         RET
  216.  
  217. InitKbdVectors  ENDP
  218.  
  219. ;*********************************************************** RestoreKbdVectors
  220.  
  221. ;Restores original vectors for INT's $09 and $16
  222.  
  223. RestoreKbdVectors       PROC FAR
  224.         PUSH    DS
  225.  
  226.         MOV     AX,PREVINT09SEG
  227.         PUSH    AX
  228.         POP     DS
  229.         MOV     DX,PREVINT09OFS
  230.         MOV     AX,2509h                ;Install old int 9
  231.         INT     21h
  232.  
  233.         MOV     AX,PREVINT05SEG
  234.         PUSH    AX
  235.         POP     DS
  236.         MOV     DX,PREVINT05OFS
  237.         MOV     AX,2505h                ;Install old int 5
  238.         INT     21h
  239.  
  240.         POP     DS
  241.  
  242.         RET
  243.  
  244. RestoreKbdVectors       ENDP
  245.  
  246. CODE    ENDS
  247.         END
  248.  
  249.  Änderungen
  250.  ----------
  251.  in 1.02ß
  252.  ------------
  253. 29.07.1994  E0FLAG Adresse korrigiert
  254.             PRINTSCREEN Absturz korrigiert
  255.             Abfangen von PAUSE korrigiert
  256.